/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ontology;

/**
 *
 * @author jamie
 */
public enum ParentInteraction implements HasParents{

    ACETYLATION("MODIFICATION"),
    PROTEIN_REGULATION("REGULATION"),
    BINDING("LOCATION_EVENT"),
    CLEAVAGE("MODIFICATION"),
    COLOCALISATION("BINDING"),
    PHOSPHORYLATION("MODIFICATION"),
    GLYCOSYLATION("MODIFICATION"),
    DEGREDATION("PHYSICAL"),
    POLYMERIZATION("MODIFICATION"),
    GENE_REGULATION("REGULATION"),
    IMPORTATION("MOVEMENT"),
    INCORPORATION("BINDING"),
    REARRANGEMENT("MODIFICATION"),
    RELEASE("MOVEMENT"),
    UNINFORMATIVE_INTERACTION(null),
    REGULATION("INFORMATIVE_INTERACTION"),
    METHYLATION("MODIFICATION"),
    MODIFICATION("PHYSICAL"),
    MOVEMENT("LOCATION_EVENT"),
    MYRISTOYLATION("MODIFICATION"),
    PALMITOYLATION("MODIFICATION"),
    POLARIZATION("MODIFICATION"),
    LOCATION_EVENT("PHYSICAL"),
    RELOCALIZATION("LOCATION_EVENT"),
    UBIQUITINATION("MODIFICATION"),
    ISOMERIZATION("MODIFICATION"),
    INFORMATIVE_INTERACTION("UNINFORMATIVE_INTERACTION"),
    PHYSICAL("INFORMATIVE_INTERACTION");

    private final String parentString;

    private ParentInteraction(String parentName){
        
        this.parentString = parentName;
        
    }

    public String getParentString() {
        return parentString;
    }


    public HasParents getParent(){
        if(this.equals(UNINFORMATIVE_INTERACTION)){
            return null;
        }
        for (ParentInteraction pi : ParentInteraction.values()) {
            if(this.parentString.equals(pi.name())){
                return pi;
            }

        }
        System.out.println(this.name());
        System.out.println(this.parentString);
        
        return null;
    }

    public boolean hasParent(HasParents p){
        if(p == null){
            return false;
        }
        else if(this.equals(UNINFORMATIVE_INTERACTION)){
            return false;
        }
        
        if(this.getParent().equals(p)){
            return true;
        } else {
            return this.getParent().hasParent(p);
        }
        
    }

    public static ParentInteraction fromString(String name){
        for(ParentInteraction pi : ParentInteraction.values()){
            if(name.equalsIgnoreCase(pi.name())){
                return pi;
            }
        }
        return null;
    }

}
